package com.ulic.customerManApplication.commonmodule.dao.impl;

import org.springframework.stereotype.Component;

import com.ulic.customerManApplication.base.BaseDao;
import com.ulic.customerManApplication.commonmodule.bo.Log;
import com.ulic.customerManApplication.commonmodule.dao.LogDao;
import com.ulic.customerManApplication.constant.CONSTANT;
import com.ulic.customerManApplication.pager.PagerModel;

@Component("logDao")
public class LogDaoImpl extends BaseDao implements LogDao {

	public void addLog(Log log) throws Exception {
		hibernateTemplate.save(log);
	}

	@Override
	public PagerModel getPager(int curPage, int logType) {
		StringBuffer hql = new StringBuffer("from Log l "); 
		if(logType>0){
			hql.append(" where l.type = "+logType);
		}
		hql.append(" order by l.time desc");
		return searchPaginated(hql.toString(), curPage, CONSTANT.PageSize);
	}

}
